package eu.vranckaert.calendar.util;

public enum WeekDay {
    SUNDAY(1),
    MONDAY(2),
    TUESDAY(3),
    WEDNESDAY(4),
    THURSDAY(5),
    FRIDAY(6),
    SATURDAY(7);

    private int weekday;

    WeekDay(int weekday) {
        this.weekday = weekday;
    }

    /**
     * Find a {@link WeekDay} by the day.
     * @param day The of the week.
     * @return The {@link WeekDay} or null if no match is found.
     */
    public static WeekDay getByDay(int day) {
        WeekDay[] weekDays = WeekDay.values();

        for (WeekDay weekDay : weekDays) {
            if (weekDay.weekday == day) {
                return weekDay;
            }
        }

        return null;
    }

    public int getWeekday() {
        return weekday;
    }
}